var ss = {
    fixAllLinks: function() {
        var b, c, a = document.getElementsByTagName("a");
        for (b = 0; b < a.length; b++) c = a[b], !c.href || -1 == c.href.indexOf("#") || c.pathname != location.pathname && "/" + c.pathname != location.pathname || c.search != location.search || ss.addEvent(c, "click", ss.smoothScroll);
    },
    smoothScroll: function(a) {
        var b, c, d, e, f, g, h;
        if (window.event) target = window.event.srcElement; else {
            if (!a) return;
            target = a.target;
        }
        if ("a" != target.nodeName.toLowerCase() && (target = target.parentNode), "a" == target.nodeName.toLowerCase()) {
            for (anchor = target.hash.substr(1), b = document.getElementsByTagName("a"), c = null, 
            d = 0; d < b.length; d++) if (e = b[d], e.name && e.name == anchor) {
                c = e;
                break;
            }
            if (c || (c = document.getElementById(anchor)), !c) return !0;
            for (f = c.offsetLeft, g = c.offsetTop, h = c; h.offsetParent && h.offsetParent != document.body; ) h = h.offsetParent, 
            f += h.offsetLeft, g += h.offsetTop;
            clearInterval(ss.INTERVAL), cypos = ss.getCurrentYPos(), ss_stepsize = parseInt((g - cypos) / ss.STEPS), 
            ss.INTERVAL = setInterval("ss.scrollWindow(" + ss_stepsize + "," + g + ',"' + anchor + '")', 10), 
            window.event && (window.event.returnValue = !1), a && a.preventDefault && a.stopPropagation && a.preventDefault();
        }
    },
    scrollWindow: function(a, b, c) {
        wascypos = ss.getCurrentYPos(), isAbove = b > wascypos, window.scrollTo(0, wascypos + a), 
        iscypos = ss.getCurrentYPos(), isAboveNow = b > iscypos, (isAbove != isAboveNow || wascypos == iscypos) && (window.scrollTo(0, b), 
        clearInterval(ss.INTERVAL), location.hash = c);
    },
    getCurrentYPos: function() {
        return document.body && document.body.scrollTop ? document.body.scrollTop : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : window.pageYOffset ? window.pageYOffset : 0;
    },
    addEvent: function(a, b, c, d) {
        if (a.addEventListener) return a.addEventListener(b, c, d), !0;
        if (a.attachEvent) {
            var e = a.attachEvent("on" + b, c);
            return e;
        }
        alert("Handler could not be removed");
    }
};

ss.STEPS = 25, ss.addEvent(window, "load", ss.fixAllLinks);